<div id="content">
    <div id="page-heading"><h1>Chi tiết hóa đơn</h1></div>
    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
        <tr>
            <th rowspan="3" class="sized"><img src="<?= base_url(); ?>images/admin_img/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
            <th class="topleft"></th>
            <td id="tbl-border-top">&nbsp;</td>
            <th class="topright"></th>
            <th rowspan="3" class="sized"><img src="<?= base_url(); ?>images/admin_img/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
        </tr>
        <tr>
            <td id="tbl-border-left"></td>
            <td>
                <!--  start content-table-inner -->
                <div id="content-table-inner">
                    <div class="table-content">
                        <div class="ct-hd">
                            <div class="quay_lai"><a href="<?= base_url(); ?>dienhoa-administrator/hoa_don/hoa_don_all">Thoát <img src="<?= base_url(); ?>images/cancel.png" width="18" height="18" class="cancel"/></a></div>
                            <? if ($hd_view): ?>
                                <table>
                                    <tr>
                                        <th class="title_infor2">Thông tin hóa đơn</th>
                                        <th class="title_infor2">Thông tin Khách hàng</th>
                                        <th class="title_infor2">Thông tin người nhận</th>
                                    </tr>
                                    <tr>
                                        <td class="col-infor">
                                            <table class="table_infor2">
                                                <tr>
                                                    <th>Mã hóa đơn</th>
                                                    <td><?= $hd_view->OID; ?></td>
                                                <tr>
                                                <tr>
                                                    <th>Ngày Lập hóa đơn</th>
                                                    <td><?= date_format(date_create($hd_view->ODate), "d-m-Y"); ?></td>
                                                </tr>
                                                <tr>
                                                    <th>Ngày xử lý hóa đơn</th>
                                                    <td><?= date_format(date_create($hd_view->OSDate), "d-m-Y"); ?></td>
                                                </tr>
                                                <tr>
                                                    <th>Trạng thái xử lý hóa đơn</th>
                                                    <td  class="colEdit">
                                                        <div class="styled-select">
                                                            <select name="select" 
                                                                    onChange="
                                                                        if(this.value == 1|| this.value == 2){ 
                                                                            window.location='<?= base_url(); ?>dienhoa-administrator/hoa_don/sua_TtHD/<?= $hd_view->OID ?>/'+this.value;} else { if(confirm('Bạn có chắc chắn sửa không?')) window.location='<?= base_url(); ?>dienhoa-administrator/hoa_don/sua_TtHD/<?= $hd_view->OID ?>/'+this.value; else this.value='<?= $hd_view->OStatus; ?>'} " 
                                                                    class="opt">
                                                                <option value="1" <? if ($hd_view->OStatus == 1) echo("selected"); ?>>Chưa xử lý</option>
                                                                <option value="2" <? if ($hd_view->OStatus == 2) echo("selected"); ?>>Đang xử lý</option>
                                                                <option value="3" <? if ($hd_view->OStatus == 3) echo("selected"); ?>>Đã xử lý</option>
                                                            </select>
                                                        </div
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <th>Hình thức thanh toán</th>
                                                    <td><?= $pay->PType; ?></td>
                                                </tr>
                                            </table>
                                        </td>
                                        <td class="col-infor">
                                            <table class="table_infor2">
                                                <? if ($kh): ?>
                                                    <tr>
                                                        <th>Tên khách hàng</th>
                                                        <td><?= $kh->CName; ?></td>
                                                    </tr>
                                                    <tr>
                                                        <th>ĐỊa chỉ</th>
                                                        <td><?= $kh->CAddress; ?></td>
                                                    </tr>
                                                    <tr>
                                                        <th>Điện thoại</th>
                                                        <td><?= $kh->CPhone; ?></td>
                                                    </tr>
                                                    <tr>
                                                        <th>Email</th>
                                                        <td><?= $kh->CEmail; ?></td>
                                                    </tr>
                                                    <tr>
                                                        <th>Trạng thái thành viên</th>
                                                        <td><? if ($kh->CStatus == 0) echo "Đang hoạt động";else echo "Đã khóa"; ?></td>
                                                    </tr>
                                                <? endif; ?>
                                            </table>
                                        </td>
                                        <td>
                                            <table class="table_infor2">
                                                <tr>
                                                    <th>Tên người nhận</th>
                                                    <td><?= $hd_view->OName; ?></td>
                                                </tr>
                                                <tr>
                                                    <th>Địa chỉ</th>
                                                    <td><?= $hd_view->OAddr; ?></td>
                                                </tr>
                                                <tr>
                                                    <th>Điện thoại</th>
                                                    <td><?= $hd_view->OPhone; ?></td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            <? endif; ?>
                            <table style="margin-top: 10px;">
                                <tr>
                                    <th class="title_infor2">Thông tin mua hàng</th>
                                </tr>
                                <tr>
                                    <td>
                                        <table class="table_infor">
                                            <? if ($hd_ct): ?>
                                                <thead>
                                                    <tr>
                                                        <th>STT</th>
                                                        <th>Mã SP</th>
                                                        <th>Tên SP</th>
                                                        <th>Số lượng</th>
                                                        <th>Giá</th>
                                                        <th>Thành tiền</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <? $i = 0 ?>
                                                    <? $tongtien = ''; ?>
                                                    <? foreach ($hd_ct as $rows): ?>
                                                        <? $i++ ?>
                                                        <tr>
                                                            <td><?= $i ?></td>
                                                            <td><?= $rows->FID; ?></td>
                                                            <td><?= $rows->FName; ?></td>
                                                            <td align="center"><?= $rows->OrderQty ?></td>
                                                            <td><?= format_price($rows->ODPrice, "VND"); ?> </td>
                                                            <td><?= format_price($rows->Amount, "VND"); ?></td>
                                                        </tr>
                                                        <? $tongtien += $rows->Amount; ?>
                                                    <? endforeach; ?>
                                                </tbody>
                                                <tfoot>
                                                    <tr>
                                                        <td colspan="5" align="right" style="color: #FF0000;">Tổng tiền:  </td>
                                                        <td style="color: #FF0000;"> <? echo format_price($tongtien, "VND"); ?></td>
                                                    </tr>
                                                <tfoot>
                                                <? endif; ?>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
                <!--  end content-table-inner  -->
            </td>
            <td id="tbl-border-right"></td>
        </tr>
        <tr>
            <th class="sized bottomleft"></th>
            <td id="tbl-border-bottom">&nbsp;</td>
            <th class="sized bottomright"></th>
        </tr>
    </table>

    <div class="clear">&nbsp;</div>
</div>
